#! /usr/bin/env python
#coding=utf-8
from get_month_quarter import *
#from get_weekreport_detail import *

#from __future__ import division


#调用get_month_quarter.py中get_db_connection()获取数据库联接
db = get_db_connection()

def set_question_priority_run():
    
    Q = get_model('question')
    
    #开始处理批处理生成的计划延迟问题优先级递增
    for row in Q.filter(and_(Q.c.planexecute != None,Q.c.status!='F')):
        if row.priority == '3':
            Q.table.update(Q.c.id == row.id).execute(priority = '2')
        if row.priority == '2':
            Q.table.update(Q.c.id == row.id).execute(priority = '1')

            
if __name__ == '__main__':
    try:
        db.begin()
        set_question_priority_run()
        db.commit()
        log.info("finish")
    except Exception, e:
        db.rollback()
        log.exception(e)
        log.error('error')
        raise
